// components/good-item/good-item.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    //common:常规布局(一般左右两列)，seckill:秒杀布局,
    //leftright:左右布局, category:分类布局 basic ：基础布局  // select:选择布局
    layoutType: {
      type: String,
      value: 'common'
    },
    itemIndex: {
      type: Number,
      optionalTypes: [Number, String],
      value: 0
    },
    paramsType: {
      type: Number,
      value: 0, // 0：取id,1:取productId
    },
    goodItem: {
      type: Object,
      value: {
        "id": 0,
        "merId": null,
        "image": "",
        "sliderImage": null,
        "storeName": "",
        "title": "",
        "storeInfo": "",
        "keyword": null,
        "barCode": null,
        "cateId": null,
        "price": "0",
        "vipPrice": null,
        "otPrice": "0",
        "postage": null,
        "unitName": null,
        "sort": null,
        "sales": 0,
        "stock": 0,
        "isShow": null,
        "isHot": null,
        "isBenefit": null,
        "isBest": null,
        "isNew": null,
        "addTime": null,
        "isPostage": null,
        "isRecycle": null,
        "isDel": null,
        "merUse": null,
        "giveIntegral": null,
        "cost": null,
        "isSeckill": null,
        "isBargain": null,
        "isGood": null,
        "isSub": null,
        "ficti": null,
        "browse": null,
        "codePath": null,
        "soureLink": null,
        "videoLink": null,
        "tempId": null,
        "specType": null,
        "activity": null,
        "flatPattern": null,
        "content": null,
        "version": null
      }
    },
    countTimestamp: {
      type: Number,
      optionalTypes: [Number, String],
      value: 0
    },
    seckillStatus: {
      type: Number,
      value: 1,//默认是进行中的
    }
  },
  observers: {
    'seckillStatus': function (value) {
      this.setData({
        seckillState: value
      })
    },

  },

  /**
   * 组件的初始数据
   */
  data: {
    seckillState: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    pushToDetail(e) {
      let type = 'normal';
      let id = e.currentTarget.dataset.id;
      //let goodType = e.currentTarget.dataset.goodType || "";
      if (this.properties.layoutType == 'seckill' && this.data.seckillState == 1) {
        console.log("JJLog:走到秒杀来了=====================")
        app.globalData.countTimestamp = this.properties.countTimestamp
        wx.navigateTo({
          url: '/shopMallPackage/pages/newStoreDetail/newStoreDetail?houseNumber=' + id + "&type=" + type + "&goodType=seckill",
        })
        return;
      }
      console.log("JJLog:是应该走这里吧=====================")
      wx.navigateTo({
        url: '/shopMallPackage/pages/newStoreDetail/newStoreDetail?houseNumber=' + id + "&type=" + type,
      })
    },
    selectAction() {
      this.triggerEvent("selectChange", { index: this.properties.itemIndex });
    },
    //取消收藏
    cancelSave() {
      this.triggerEvent("cancelSave", { index: this.properties.itemIndex });
    },
  }
})
